a = int(input())
b = int(input())
c = 0
if (b > a):
    c = a
    a = b
    b = c
while (1):
    c = a % b
    if c == 0:
        print(b)
        break
    else:
        a=b
        b=c
